﻿using System;
using System.Diagnostics.Contracts;
using System.Reflection;
using Beaker.Injection;

namespace OpenCube.Nbt.Mapping
{
	internal sealed class ConversionContext
		: IConversionContext
	{
		private readonly IQueryContainer _queryContainer;
		private readonly MemberInfo _memberInfo;
		private readonly INbtDictionary _nbtDictionary;

		public ConversionContext(IQueryContainer queryContainer, MemberInfo memberInfo = null, INbtDictionary nbtDictionary = null)
		{
			Contract.Requires<ArgumentNullException>(queryContainer != null);

			_queryContainer = queryContainer;
			_memberInfo = memberInfo;
			_nbtDictionary = nbtDictionary;
		}

		/// <summary>
		/// Gets the <see cref="IQueryContainer"/> to query manually for DI instances.
		/// </summary>
		public IQueryContainer QueryContainer
		{
			get { return _queryContainer; }
		}

		/// <summary>
		/// Gets the member info that provides you with property or class being convert to/from
		/// </summary>
		public MemberInfo MemberInfo
		{
			get { return _memberInfo; }
		}

		/// <summary>
		/// Gets the NBT dictionary holding the source/target NBT key value store.
		/// </summary>
		public INbtDictionary NbtDictionary
		{
			get { return _nbtDictionary; }
		}
	}
}